<template>
  <div class="box">
    <ul>
      <li v-for="item in list" :key="item.proid">
        <RouterLink :to="'/details/' + item.proid">
          <img :src="item.img1" alt="" />
          <p>{{ item.proname }}</p>
          <span>￥{{ item.originprice }}</span>
        </RouterLink>
      </li>
    </ul>
  </div>
</template>
<script lang="ts" setup>
import { recommendList } from "../../server/produce";
import { ref, onMounted } from "vue";
let list = ref<any>([]);

onMounted(() => {
  getList();
});

function getList() {
  recommendList().then((res: any) => {
    if (res.code === "200") {
      list.value = res.data;
    }
  });
}
</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  ul {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    li {
      width: 50%;
      box-sizing: border-box;
      padding: 10px;
      img {
        display: block;
        width: 100%;
      }
      p {
        font-size: 16px;
        overflow: hidden; /*文本超出隐藏*/
        display: -webkit-box; /*盒子模型微弹性伸缩模型*/
        -webkit-box-orient: vertical; /*伸缩盒子的子元素垂直排列*/
        -webkit-line-clamp: 1; /*文本显示3行*/
      }
      span {
        color: red;
        font-size: 16px;
      }
    }
  }
}
a {
  color: black;
}
</style>
